<script lang="ts" setup>
import i18n from '@/i18n'

console.log(i18n.global.locale)

function changeZh(): void {
  i18n.global.locale = 'zh'
}

function chlang(lang: any): void {
  i18n.global.locale = lang
}
</script>

<template>
  <h3>vue-i18n</h3>

  <p>{{ $t('message.hello') }}</p>
  <button>{{ $t('message.submit') }}</button>
  <p>{{ $t('message.address') }}</p>
  <hr>
  <!-- npm i vue-i18n --save 用如下方法 -->
  <button @click="$i18n.locale='zh'">中文</button>
  <button @click="changeZh">中文-changeZh()</button>
  <button @click="$i18n.locale='en'">英文</button>
  <button @click="$i18n.locale='ja'">日文</button>
  <button @click="chlang('ja')">日文-chlang('ja')</button>
  <button @click="chlang('zhTw')">台湾</button>
</template>

<style lang="scss" scoped>

</style>
